<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>类别列表</title>
</head>
<body style="text-align:center">
	<h2>类别列表</h2>
	<a href="addCategory">添加类别</a>
	<table align='center' border='1' cellspacing='0'>
    <tr>
        <td>编号</td>
        <td>类别</td>
        <td>编辑</td>
        <td>删除</td>
    </tr>
    <c:forEach items="${list}" var="a">
        <tr>
            <td>${a.id}</td>
            <td>${a.name}</td>
            <td><button type="button" class="btn btn-primary" onclick="location='editCategory?id=${a.id}'">修改</button></td>
            <td><button type="button" class="btn btn-warning" onclick="delete_comfirm(${a.id})">删除</button></td>
        </tr>
    </c:forEach>
	</table>
	<div style="text-align:center">
		<a href="?start=0">首　页</a>
		<c:if test="${page.start != 0}">
			<a href="?start=${page.start-page.count}">上一页</a>
		</c:if>
		<c:if test="${page.start !=  page.last}">
			<a href="?start=${page.start+page.count}">下一页</a>
		</c:if>
		<a href="?start=${page.last}">末　页</a>
	</div>
</body>
</html>
<script>
/**
 *     删除提示方法
 * @param id
 */
function  delete_comfirm(id) {
	if(confirm("你确定要删除这个类别吗？")){
		window.location.replace("deleteCategory?id="+id);
	}
}
</script>